/**
 * @Description:
 * @author 云离
 * @date: 2020-02-05
 */
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { withRouter } from 'react-router-dom'
class Auth extends Component {
    static propTypes = {
        children: PropTypes.object,
        location: PropTypes.object,
        isLogin: PropTypes.bool,
        history: PropTypes.object
    };
    componentDidMount () {
        if (!this.props.isLogin) {
            setTimeout(() => {
                this.props.history.replace('/login')
            }, 300)
        }
    }

    componentDidUpdate () {
        if (!this.props.isLogin) {
            setTimeout(() => {
                this.props.history.replace('/login')
            }, 300)
        }
    }
    render () {
        return this.props.children
    }
}
export default withRouter(Auth)
